// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Serverless.Core;
using Elastic.Clients.Elasticsearch.Serverless.Fluent;
using Elastic.Clients.Elasticsearch.Serverless.Serialization;
using Elastic.Transport;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.Serverless.Aggregations;

public partial interface IAggregate
{
}

[JsonConverter(typeof(AggregateDictionaryConverter))]
public partial class AggregateDictionary : IsAReadOnlyDictionary<string, IAggregate>
{
	public AggregateDictionary(IReadOnlyDictionary<string, IAggregate> backingDictionary) : base(backingDictionary)
	{
	}

	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.AdjacencyMatrixAggregate? GetAdjacencyMatrix(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.AdjacencyMatrixAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.AutoDateHistogramAggregate? GetAutoDateHistogram(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.AutoDateHistogramAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.AverageAggregate? GetAverage(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.AverageAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.BoxplotAggregate? GetBoxplot(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.BoxplotAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.BucketMetricValueAggregate? GetBucketMetricValue(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.BucketMetricValueAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.CardinalityAggregate? GetCardinality(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.CardinalityAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.ChildrenAggregate? GetChildren(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ChildrenAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.CompositeAggregate? GetComposite(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.CompositeAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.CumulativeCardinalityAggregate? GetCumulativeCardinality(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.CumulativeCardinalityAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.DateHistogramAggregate? GetDateHistogram(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.DateHistogramAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.DateRangeAggregate? GetDateRange(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.DateRangeAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.DerivativeAggregate? GetDerivative(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.DerivativeAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.DoubleTermsAggregate? GetDoubleTerms(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.DoubleTermsAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedStatsAggregate? GetExtendedStats(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedStatsAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedStatsBucketAggregate? GetExtendedStatsBucket(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedStatsBucketAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.FilterAggregate? GetFilter(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.FilterAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.FiltersAggregate? GetFilters(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.FiltersAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.FrequentItemSetsAggregate? GetFrequentItemSets(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.FrequentItemSetsAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoBoundsAggregate? GetGeoBounds(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoBoundsAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoCentroidAggregate? GetGeoCentroid(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoCentroidAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoDistanceAggregate? GetGeoDistance(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoDistanceAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeohashGridAggregate? GetGeohashGrid(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeohashGridAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeohexGridAggregate? GetGeohexGrid(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeohexGridAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoLineAggregate? GetGeoLine(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoLineAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeotileGridAggregate? GetGeotileGrid(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeotileGridAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.GlobalAggregate? GetGlobal(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GlobalAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.HdrPercentileRanksAggregate? GetHdrPercentileRanks(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.HdrPercentileRanksAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.HdrPercentilesAggregate? GetHdrPercentiles(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.HdrPercentilesAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.HistogramAggregate? GetHistogram(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.HistogramAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.InferenceAggregate? GetInference(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.InferenceAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.IpPrefixAggregate? GetIpPrefix(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.IpPrefixAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.IpRangeAggregate? GetIpRange(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.IpRangeAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.LongRareTermsAggregate? GetLongRareTerms(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.LongRareTermsAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.LongTermsAggregate? GetLongTerms(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.LongTermsAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.MatrixStatsAggregate? GetMatrixStats(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MatrixStatsAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.MaxAggregate? GetMax(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MaxAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.MedianAbsoluteDeviationAggregate? GetMedianAbsoluteDeviation(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MedianAbsoluteDeviationAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.MinAggregate? GetMin(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MinAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.MissingAggregate? GetMissing(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MissingAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.MultiTermsAggregate? GetMultiTerms(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MultiTermsAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.NestedAggregate? GetNested(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.NestedAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.ParentAggregate? GetParent(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ParentAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.PercentilesBucketAggregate? GetPercentilesBucket(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.PercentilesBucketAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.RangeAggregate? GetRange(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.RangeAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.RateAggregate? GetRate(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.RateAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.ReverseNestedAggregate? GetReverseNested(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ReverseNestedAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.SamplerAggregate? GetSampler(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.SamplerAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.ScriptedMetricAggregate? GetScriptedMetric(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ScriptedMetricAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.SignificantLongTermsAggregate? GetSignificantLongTerms(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.SignificantLongTermsAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.SignificantStringTermsAggregate? GetSignificantStringTerms(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.SignificantStringTermsAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.SimpleValueAggregate? GetSimpleValue(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.SimpleValueAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.StatsAggregate? GetStats(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.StatsAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.StatsBucketAggregate? GetStatsBucket(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.StatsBucketAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.StringRareTermsAggregate? GetStringRareTerms(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.StringRareTermsAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.StringStatsAggregate? GetStringStats(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.StringStatsAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.StringTermsAggregate? GetStringTerms(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.StringTermsAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.SumAggregate? GetSum(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.SumAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.TDigestPercentileRanksAggregate? GetTDigestPercentileRanks(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.TDigestPercentileRanksAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.TDigestPercentilesAggregate? GetTDigestPercentiles(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.TDigestPercentilesAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.TopHitsAggregate? GetTopHits(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.TopHitsAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.TopMetricsAggregate? GetTopMetrics(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.TopMetricsAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.TTestAggregate? GetTTest(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.TTestAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.UnmappedRareTermsAggregate? GetUnmappedRareTerms(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.UnmappedRareTermsAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.UnmappedSamplerAggregate? GetUnmappedSampler(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.UnmappedSamplerAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.UnmappedSignificantTermsAggregate? GetUnmappedSignificantTerms(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.UnmappedSignificantTermsAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.UnmappedTermsAggregate? GetUnmappedTerms(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.UnmappedTermsAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.ValueCountAggregate? GetValueCount(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ValueCountAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.VariableWidthHistogramAggregate? GetVariableWidthHistogram(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.VariableWidthHistogramAggregate>(key);
	public Elastic.Clients.Elasticsearch.Serverless.Aggregations.WeightedAverageAggregate? GetWeightedAverage(string key) => TryGet<Elastic.Clients.Elasticsearch.Serverless.Aggregations.WeightedAverageAggregate>(key);
	private T? TryGet<T>(string key) where T : class, IAggregate => BackingDictionary.TryGetValue(key, out var value) ? value as T : null;
}

internal sealed partial class AggregateDictionaryConverter : JsonConverter<AggregateDictionary>
{
	public override AggregateDictionary Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
	{
		var dictionary = new Dictionary<string, IAggregate>();
		if (reader.TokenType != JsonTokenType.StartObject)
			throw new JsonException($"Expected {JsonTokenType.StartObject} but read {reader.TokenType}.");
		while (reader.Read() && reader.TokenType != JsonTokenType.EndObject)
		{
			if (reader.TokenType != JsonTokenType.PropertyName)
				throw new JsonException($"Expected {JsonTokenType.PropertyName} but read {reader.TokenType}.");
			var name = reader.GetString();
			reader.Read();
			ReadItem(ref reader, options, dictionary, name);
		}

		return new AggregateDictionary(dictionary);
	}

	public override void Write(Utf8JsonWriter writer, AggregateDictionary value, JsonSerializerOptions options)
	{
		throw new NotImplementedException("'AggregateDictionary' is a readonly type, used only on responses and does not support being written to JSON.");
	}

	public static void ReadItem(ref Utf8JsonReader reader, JsonSerializerOptions options, Dictionary<string, IAggregate> dictionary, string name)
	{
		var nameParts = name.Split('#');
		if (nameParts.Length != 2)
			throw new JsonException($"Unable to parse typed-key '{name}'.");
		var type = nameParts[0];
		switch (type)
		{
			case "adjacency_matrix":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.AdjacencyMatrixAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "auto_date_histogram":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.AutoDateHistogramAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "avg":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.AverageAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "boxplot":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.BoxplotAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "bucket_metric_value":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.BucketMetricValueAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "cardinality":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.CardinalityAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "children":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ChildrenAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "composite":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.CompositeAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "simple_long_value":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.CumulativeCardinalityAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "date_histogram":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.DateHistogramAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "date_range":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.DateRangeAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "derivative":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.DerivativeAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "dterms":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.DoubleTermsAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "extended_stats":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedStatsAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "extended_stats_bucket":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedStatsBucketAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "filter":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.FilterAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "filters":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.FiltersAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "frequent_item_sets":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.FrequentItemSetsAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "geo_bounds":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoBoundsAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "geo_centroid":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoCentroidAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "geo_distance":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoDistanceAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "geohash_grid":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeohashGridAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "geohex_grid":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeohexGridAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "geo_line":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoLineAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "geotile_grid":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeotileGridAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "global":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GlobalAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "hdr_percentile_ranks":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.HdrPercentileRanksAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "hdr_percentiles":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.HdrPercentilesAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "histogram":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.HistogramAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "inference":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.InferenceAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "ip_prefix":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.IpPrefixAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "ip_range":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.IpRangeAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "lrareterms":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.LongRareTermsAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "lterms":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.LongTermsAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "matrix_stats":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MatrixStatsAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "max":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MaxAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "median_absolute_deviation":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MedianAbsoluteDeviationAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "min":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MinAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "missing":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MissingAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "multi_terms":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MultiTermsAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "nested":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.NestedAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "parent":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ParentAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "percentiles_bucket":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.PercentilesBucketAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "range":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.RangeAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "rate":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.RateAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "reverse_nested":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ReverseNestedAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "sampler":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.SamplerAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "scripted_metric":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ScriptedMetricAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "siglterms":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.SignificantLongTermsAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "sigsterms":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.SignificantStringTermsAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "simple_value":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.SimpleValueAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "stats":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.StatsAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "stats_bucket":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.StatsBucketAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "srareterms":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.StringRareTermsAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "string_stats":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.StringStatsAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "sterms":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.StringTermsAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "sum":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.SumAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "tdigest_percentile_ranks":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.TDigestPercentileRanksAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "tdigest_percentiles":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.TDigestPercentilesAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "top_hits":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.TopHitsAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "top_metrics":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.TopMetricsAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "t_test":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.TTestAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "umrareterms":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.UnmappedRareTermsAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "unmapped_sampler":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.UnmappedSamplerAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "umsigterms":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.UnmappedSignificantTermsAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "umterms":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.UnmappedTermsAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "value_count":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ValueCountAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "variable_width_histogram":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.VariableWidthHistogramAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			case "weighted_avg":
				{
					var item = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.WeightedAverageAggregate>(ref reader, options);
					dictionary.Add(nameParts[1], item);
					break;
				}

			default:
				throw new NotSupportedException($"The tagged variant '{type}' is currently not supported.");
		}
	}
}